//引入路由对象
import { createRouter, createWebHistory, createWebHashHistory, createMemoryHistory, RouteRecordRaw } from 'vue-router'



// 路由数组的类型 RouteRecordRaw
// 定义一些路由
// 每个路由都需要映射到一个组件。
// const routes: Array<RouteRecordRaw> = [{
//     path: '/',
//     name: "Login",// name指定名字,如果你不想通过path这种硬编码的形式来操作的话,要修改router-link
//     // component: () => import('../components/login-1.vue')
//     component: () => import('../components/login.vue')
// },{
//     // path: '/reg',
//     path: '/reg/:id',// 第4章，动态路由参数
//     name: 'Reg',
//     component: () => import('../components/reg.vue')
// }]

// 5 嵌套路由
const routes: Array<RouteRecordRaw> = [
    {
        path: "/user",
        component: () => import('../components/footer.vue'),
        children: [
            {
                path: "",
                name: "Login",
                component: () => import('../components/login.vue')
            },
            {
                path: "reg",
                name: "Reg",
                component: () => import('../components/reg.vue')
            }
        ]
    },
]

//vue2 mode     history     vue3 createWebHistory
//vue2 mode     hash        vue3  createWebHashHistory
//vue2 mode     abstact     vue3  createMemoryHistory
const router = createRouter({
    history: createWebHistory(),
    routes
})

//导出router,需要在mian.ts下注册一下
export default router